package com.zziq.mianshi.common;

/**
 * 返回工具类
 */
public class ResultUtils {

    /** @Title: success
     * @Author: Mr·zziq
     * @Date: 2024-12-04 18:53:29
     * @Params: [data]
     * @Return: BaseResponse<T>
     * @Description: 成功
     */
    public static <T> BaseResponse<T> success(T data) {
        return new BaseResponse<>(0, data, "ok");
    }

    /** @Title: error
     * @Author: Mr·zziq
     * @Date: 2024-12-04 18:53:17
     * @Params: [errorCode]
     * @Return: BaseResponse
     * @Description: 失败+枚举状态码
     */
    public static BaseResponse error(ErrorCode errorCode) {
        return new BaseResponse<>(errorCode);
    }

    /** @Title: error
     * @Author: Mr·zziq
     * @Date: 2024-12-04 18:54:00
     * @Params: [code, message]
     * @Return: BaseResponse
     * @Description: 失败+提示信息+自定义状态码
     */
    public static BaseResponse error(int code, String message) {
        return new BaseResponse(code, null, message);
    }

    /** @Title: error
     * @Author: Mr·zziq
     * @Date: 2024-12-04 18:54:16
     * @Params: [errorCode, message]
     * @Return: BaseResponse
     * @Description: 失败+提示信息+枚举状态码
     */
    public static BaseResponse error(ErrorCode errorCode, String message) {
        return new BaseResponse(errorCode.getCode(), null, message);
    }
}
